package service.impl;

import java.util.List;

import service.CalculateRoadStatus;
import service.RoadService;
import bean.Segment;
import bean.Vehicle;
import dao.impl.StaticData;

public class CalculateRoadStatusImpl implements CalculateRoadStatus {

	private static Thread currentThread = null;
	private RoadService roadService;
	private int area;
	private List<Vehicle> vs;
	private StaticData staticData;
	public static int running;

	public List<Vehicle> getVs() {
		return vs;
	}

	public void setVs(List<Vehicle> vs) {
		this.vs = vs;
	}

	public int getArea() {
		return area;
	}

	public StaticData getStaticData() {
		return staticData;
	}

	@Override
	public void setStaticData(StaticData staticData) {
		this.staticData = staticData;
	}

	public RoadService getRoadService() {
		return roadService;
	}

	public void setRoadService(RoadService roadService) {
		this.roadService = roadService;
	}

	public CalculateRoadStatusImpl() {

	}

	@Override
	public void run() {
		running=RUNNING;
		getCurrentMovement();
		// 计算道路状态，持续计算。按时间段统计。
		getSegment();
		List<Segment> segs = Segment.segs;
		if (segs != null) {
			System.out.println("ok");
			for (int i = 0; i < segs.size(); i++) {
				System.out.println(segs.get(i) + "......");
			}
		}else{
			System.out.println("fuck!");
		}
	
	}
	
	private void getSegment(){
		Segment seg_temp=new Segment();
		seg_temp.calSegment(area);
	}

	@Override
	public List<Vehicle> getCurrentMovement() {
		this.vs = Vehicle.ves;
		return this.vs;
	}

	@Override
	public Thread getCurrentThread() {
		if(currentThread==null)
			currentThread = new Thread(this);
		return currentThread;
	}

	@Override
	public void setArea(int area) {
		this.area = area;
	}
	
	@Override
	public int modeStatus() {
		return running;
	}
}
